{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="user_code" class="col-sm-2 control-label">编号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="user_code" name="user_code" value="{$data.user_code|default=''}" placeholder="请输入编号" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">姓名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="username" name="username" value="{$data.username|default=''}" placeholder="请输入姓名" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="qq" class="col-sm-2 control-label">QQ</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="qq" name="qq" value="{$data.qq|default=''}" placeholder="请输入qq" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mobile" class="col-sm-2 control-label">手机号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="mobile" name="mobile" value="{$data.mobile|default=''}" placeholder="请输入手机号" type="tel" maxlength="11" class="form-control field-mobile">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="pid" class="col-sm-2 control-label">所属站长</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="pid" id="pid" class="form-control field-select" data-placeholder="请选择站长名称">
                                    <option value="">请选择...</option>
                                    {foreach name="sta" item="vo"}
                                    <option value="{$vo.id}" {if isset($data) && $data.pid==$vo.id} selected {/if}>{$vo.username}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="bid" class="col-sm-2 control-label">银行名称</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="bid" id="bid" class="form-control field-select" data-placeholder="请选择银行名称">
                                    <option value="">请选择...</option>
                                    {foreach name="bank" item="vo"}
                                    <option value="{$vo.id}" {if isset($data) && $data.bid==$vo.id} selected {/if}>{$vo.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="re_id" class="col-sm-2 control-label">推荐人ID</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="re_id" name="re_id" value="{$data.re_id|default='0'}" placeholder="请填写推荐人id" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="bank_name" class="col-sm-2 control-label">开户姓名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="bank_name" name="bank_name" value="{$data.bank_name|default=''}" placeholder="请输入开户姓名" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="bank_code" class="col-sm-2 control-label">银行卡号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="bank_code" name="bank_code" value="{$data.bank_code|default=''}" placeholder="请输入银行卡号" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                状态
                                <!--1 正常 0待审核 -1驳回 -2冻结 -3隐藏-->
                            </label>
                            <div class="col-sm-10 col-md-4" style="padding:5px;">&nbsp;
                                <input type="radio" name="status" value="1" {if isset($data) && $data.status==1} checked {/if} />&nbsp;正常&nbsp;
                                <input type="radio" name="status" value="0" {if isset($data) && $data.status==0} checked {/if} />&nbsp;待审核&nbsp;
                                <input type="radio" name="status" value="-1" {if isset($data) && $data.status==-1} checked {/if} />&nbsp;驳回&nbsp;
                                <input type="radio" name="status" value="-2" {if isset($data) && $data.status==-2} checked {/if} />&nbsp;冻结&nbsp;
                                <input type="radio" name="status" value="-3" {if isset($data) && $data.status==-3} checked {/if} />&nbsp;隐藏
                            </div>
                        </div>

                        <script>
                            $('#status').bootstrapSwitch({
                                onText: "是",
                                offText: "否",
                                onColor: "success",
                                offColor: "danger",
                                onSwitchChange: function (event, state) {
                                    $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
                                }
                            });
                        </script>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'user_code': {
                required: true,
            },
            'username': {
                required: true,
            },
            'qq': {
                required: true,
            },
            'mobile': {
                required: true,
            },
            'pid': {
                required: true,
            },
            're_id': {
                required: false,
            },
            'bid': {
                required: true,
            },
            'bank_name': {
                required: true,
            },
            'bank_code': {
                required: true,
            },
            'status': {
                required: true,
            },

        },
        messages: {
            'user_code': {
                required: "编号不能为空",
            },
            'username': {
                required: "姓名不能为空",
            },
            'qq': {
                required: "qq不能为空",
            },
            'mobile': {
                required: "手机号不能为空",
            },
            'pid': {
                required: "所属站长id不能为空",
            },
            're_id': {
                required: "推荐人id不能为空",
            },
            'bid': {
                required: "银行名称不能为空",
            },
            'bank_name': {
                required: "开户姓名不能为空",
            },
            'bank_code': {
                required: "银行卡号不能为空",
            },
            'status': {
                required: "1 正常 0待审核 -1驳回 -2冻结 -3隐藏不能为空",
            },

        }
    });
</script>
{/block}